<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap-grid.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.js
    "></script>
    <title>Document</title>
</head>
<body>
    <div class="container">
        <h2 class="page-header">基本使用</h2>
        <button class="btn btn-primary">发送GET请求</button>
        <button class="btn btn-primary">发送POST请求</button>
        <button class="btn btn-primary">发送PUT请求</button>
        <button class="btn btn-primary">发送DELETE请求</button>
    </div>
    <script>
        //获取按钮
        const btns=document.querySelectorAll('button');
        //axios
        //创建实例对象  /https://api.apiopen.top/getJoke
       const duanzi=axios.create({
            baseURL:"https://api.apiopen.top",
           timeout:2000,
       });
       const onather=axios.create({
            baseURL:"https://b.com",
           timeout:2000,
       });
       //这里duanzi 与axios 对象的功能几近是一样的
       console.log(duanzi);
    //    duanzi({
    //        url:'/getJoke',
    //    }).then(response=>{
    //        console.log(response);
    //    })
       duanzi.get("/getJoke").then(response=>{
           console.log(response);
       })


    </script>
</body>
</html>